﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using Transcend.FileUploader.Entity;
using Transcend.FileUploader.Utility;

namespace Transcend.FileUploader.Dao
{
    /// <summary>
    /// DSPage -> DocPage 映射类
    /// </summary>
    class DocPageMapper : Transcend.DP3.Db.IReaderMapper<DocPage>
    {

       public DocPage Map(DbDataReader dr)
       {
//ID,
//       PAGE_NO,
//       STATUS,
//       IMAGE_SIZE,
//       PAGE_NUM,
//       RAW_FILE_NAME,
//       USER_ID,
//       IMG_WIDTH,
//       IMG_HEIGHT,
//       STORE_FILE_NAME,
//       ITEM_ID,
//       CREATE_USER_ID,
//       MODIFY_USER_ID,
//       CREATE_DATE,
//       MODIFY_DATE,
//       DIVISION_ID

           DocPage page = new DocPage();
           page.CreateDate = Transcend.DP3.Db.Database.GetValue<DateTime>(dr, "CREATE_DATE");
           page.Data = null;
		   page.Id = Transcend.DP3.Db.Database.GetValue<decimal>(dr, "ID".ToString(), -1);
           page.Size = Transcend.DP3.Db.Database.GetValue<long>(dr, "IMAGE_SIZE", 0);
           page.ItemId = Transcend.DP3.Db.Database.GetValue<decimal>(dr, "ITEM_ID".ToString(), -1);
		   //page.Keyword = Transcend.DP3.Db.Database.GetValue<string>(dr, "keyword", string.Empty);
           page.PageNo = Transcend.DP3.Db.Database.GetValue<int>(dr, "PAGE_NO", 0);
           page.PageNum = Transcend.DP3.Db.Database.GetValue<int>(dr, "PAGE_NUM", 0);
           page.RawFileName = Transcend.DP3.Db.Database.GetValue<string>(dr, "RAW_FILE_NAME", string.Empty);
           page.Status = Transcend.DP3.Db.Database.GetValue<int>(dr, "STATUS", 0);
        //   page.UpdateTime = Transcend.DP3.Db.Database.GetValue<DateTime>(dr, "MODIFY_DATE",DateTime.Now);
           var id_Name= Transcend.DP3.Db.Database.GetValue<string>(dr, "CREATE_USER_ID".ToString(), string.Empty);
           page.UserId = decimal.Parse(id_Name.Substring(0, id_Name.IndexOf("(")));
		//   page.UserName = Transcend.DP3.Db.Database.GetValue<string>(dr, "username", string.Empty);
           return page;
       }

    }
}
